|
Duplicate code is a computer programming term for a sequence of source code that occurs more than once, either within a program or across different programs owned or maintained by the same entity. Duplicate code is generally considered undesirable for a number of reasons. A minimum requirement is usually applied to the quantity of code that must appear in a sequence for it to be considered duplicate rather than coincidentally similar. Sequences of duplicate code are sometimes known as code clones or just clones, the automated process of finding duplications in source code is called clone detection. The following are some of the ways in which two code sequences can be duplicates of each other: * character-for-character identical * character-for-character identical with white space characters and comments being ignored * token-for-token identical * token-for-token identical with occasional variation (i.e., insertion/deletion/modification of tokens) * functionally identical ==How duplicates are created== There are a number of reasons why duplicate code may be created, including: *Copy and paste programming, or scrounging, in which a section of code is copied "because it works". In most cases this operation involves slight modifications in the cloned code such as renaming variables or inserting/deleting code. *Functionality that is very similar to that in another part of a program is required and a developer independently writes code that is very similar to what exists elsewhere. Studies suggest, that such independently rewritten code is typically not syntactically similar.〔(Code similarities beyond copy & paste ) by Elmar Juergens, Florian Deissenboeck, Benjamin Hummel.〕〔Stefan Wagner, Asim Abdulkhaleq, Ivan Bogicevic, Jan-Peter Ostberg, Jasmin Ramadani. (How are functionally similar code clones different? ) PeerJ Preprints, 2015.〕 *Plagiarism, where code is simply copied without permission or attribution. *Generated code, where having duplicate code may be desired to increase speed or ease of development. Note that the actual generator will not contain duplicates in its source code, only the output it produces. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「duplicate code」の詳細全文を読む スポンサード リンク
|